<?php
/**
 * Function:
 * Description:
 * Abo 2018/10/10 18:19
 * Email: abo2013@foxmail.com
 */

$client = new swoole_client( SWOOLE_SOCK_UDP );

if ( !$client->connect( '127.0.0.1', 9502 ) ) {
    die( '链接失败' );
}

// php cli常量 获取cli输入输出内容
fwrite( STDOUT, "请输入消息!\r\n" );
$msg = trim( fgets( STDIN ) );

// 发送消息
$client->send( $msg );

//接收来自server的数据
$result = $client->recv();
echo $result . "\r\n";